# Create your models here.
from django.db import models

class Nhom_Nganh(models.Model):
    ten_nhom_nganh = models.CharField(max_length=100)
    mo_ta = models.TextField(blank=True,null=True)
    ma_nhom_nganh = models.CharField(max_length=10, primary_key=True)
    ky_nang_yeu_cau = models.TextField(null=True, blank=True)

    def __unicode__(self):
        return self.ten_nhom_nganh

class Nganh(models.Model):
    ten_nganh = models.CharField(max_length=100)
    mo_ta = models.TextField(blank=True,null=True)
    ma_nganh = models.CharField(max_length=10, primary_key=True)
    ky_nang_yeu_cau = models.TextField(null=True, blank=True)
    nhom_nganh = models.ForeignKey(Nhom_Nganh)

    def __unicode__(self):
        return self.ten_nganh

class Nghe(models.Model):
    ten_nghe = models.CharField(max_length=100)
    mo_ta = models.TextField(blank=True,null=True)
    ma_nghe = models.AutoField(primary_key=True)
    cac_nganh_can_hoc = models.ManyToManyField(Nganh)
    thong_tin_tuyen_dung = models.TextField(null=True, blank=True)

    def __unicode__(self):
        return self.ten_nghe

class Truong(models.Model):
    ten_truong = models.CharField(max_length=100)
    mo_ta = models.TextField(blank=True,null=True)
    ma_truong = models.CharField(max_length=10, primary_key=True)
    thong_tin_hoc_phi = models.TextField(null=True, blank=True)

    def __unicode__(self):
        return self.ten_truong

class Khoa(models.Model):
    ten_khoa = models.CharField(max_length=100)
    mo_ta = models.TextField(blank=True,null=True)
    ma_khoa = models.CharField(max_length=30, primary_key=True)
    giang_day = models.ManyToManyField(Nganh, through='Dao_Tao')
    truong = models.ForeignKey(Truong)

    def __unicode__(self):
        return 'khoa ' + self.ten_khoa + ' of ' + self.truong.ten_truong

class Thong_Tin_Chung(models.Model):
    thong_tin = models.TextField(blank=True,null=True)
    ma_thong_tin = models.AutoField(primary_key=True)
    thoi_gian = models.DateTimeField(blank=True,null=True)

    def __unicode__(self):
        return self.thong_tin[0:50]

class Choices(models.Model):
    LUA_CHON_KHOI_THI = (
        ('A', 'A : Toan, Ly, Hoa'),
        ('A1', 'A1: Toan, Ly, Anh'),
        ('B', 'B : Sinh, Toan, Hoa'),
        ('C', 'C : Van, Su, Dia'),
        ('D1', 'D1: Van, Toan, Tieng Anh'),
        ('D2', 'D2: Van, Toan, Tieng Nga'),
        ('D3', 'D3: Van, Toan, Tieng Phap'),
        ('D4', 'D4: Van, Toan, Tieng Trung'),
        ('D5', 'D5: Van, Toan, Tieng Duc'),
        ('D6', 'D6: Van, Toan, Tieng Nhat'),
        ('V', 'V : Toan, Ly, Ve'),
        ('V1', 'V1: Toan, Van, Ve'),
        ('T', 'T : Sinh, Toan, Nang khieu TDTT'),
        ('M', 'M : Van, Toan, Nang khieu'),
        ('N', 'N : Van, Nhac, Nhac'),
        ('H', 'H : Van, Nang khieu, My thuat'),
        ('H1', 'H1: Toan, Van, Ve'),
        ('R', 'R : Van, Su, Nang khieu bao chi'),
        ('S', 'S : Van, Dien anh, Dien anh'),
        ('K', 'K : Toan, Ly, Ky thuat nghe'),
    )
    description = models.CharField(choices=LUA_CHON_KHOI_THI, max_length=2)
    def __unicode__(self):
        return self.description

class Dao_Tao(models.Model):
    nganh = models.ForeignKey(Nganh)
    khoa = models.ForeignKey(Khoa)
    nam_tuyen_sinh = models.DateField(blank=True,null=True)
    so_luong_dang_ky_thi = models.IntegerField(blank=True,null=True)
    chi_tieu_tuyen_sinh = models.IntegerField(blank=True,null=True)
    diem_chuan = models.FloatField(blank=True,null=True)
    khoi_thi = models.ManyToManyField(Choices)
    diem_chuan_nv2 = models.FloatField(blank=True,null=True)
    chi_tieu_nv2 = models.IntegerField(blank=True,null=True)
    ghi_chu = models.TextField(blank=True,null=True)


# class Choices(models.Model):
#   description = models.CharField(max_length=300)
#
# class Profile(models.Model):
#   user = models.ForeignKey(User, blank=True, unique=True, verbose_name='user')
#   choices = models.ManyToManyField(Choices)

    def __unicode__(self):
        return 'Khoa ' + self.khoa.ten_khoa + ' of truong ' + self.khoa.truong.ten_truong + ' dao tao ' +self.nganh.ten_nganh

